<template>
	<view class="form b_width">

		<view class="i_box">

			<input v-model="form.nickname" placeholder="请输入姓名" />

		</view>

		<view class="i_box">

			<input v-model="form.mobile" placeholder="请输入手机号" />

		</view>

		<view class="btn" @click="submit">提交</view>

		<view class="agree ag_box">
			<view class="iconfont fs-18" :class="check?'icondanxuanfuxuan':'iconico2'" @click="check=!check"></view>
			<view class="text_box">
				<view>我已阅读并同意</view>
				<view v-for="(item,index) in xyList" :key="index" @click="toUrl(item)" class="protocol">{{item.title}}
				</view>
			</view>
		</view>

		<bottom  value="会员注册"></bottom>
	</view>
</template>

<script>
	import bottom from "@/components/bottom.vue";
	export default {
		components: {
			bottom
		},
		data() {
			return {
				check: '',
				xyList: [],
				form: {
					nickname: '',
					mobile: ''
				}
			};
		},
		onShow() {
			this.getXy();
		},
		onLoad() {
			uni.hideTabBar();
		},
		methods: {
			submit(){
				if(!this.check) return this.$Toast('请确认协议');
				if(!this.form.nickname) return this.$Toast('请输入姓名');
				if(!this.form.mobile) return this.$Toast('请输入电话');
				let _=this;
				uni.showModal({
					title: '温馨提示',
					content: '是否确认提交',
					showCancel: true,
					
					success(ress) {
						if (ress.confirm) {
							_.setUser();
						}
					}
				});
				
			},
			setUser(){
				this.$post(this.$api.userWeb,this.form,res=>{
					 let {data,code,msg}=res.data;
					this.$Toast(msg);
					 if(code==1){
						 
						 setTimeout(()=>{
							this.form={
							 	nickname: '',
							 	mobile: ''
							 }
							 uni.switchTab({
							 	url:'/pages/tabar/index'
							 })
						 },1000);
					 }
				});
			},
			toUrl(e) {
				uni.navigateTo({
					url: '/pages/news/info?id=' + e.id
				})
			},
			getXy() {
				let _ = this;
				_.$get(_.$api.newsNews, {
					cate_id: 16,
					type: 2
				}, (res) => {
					let {
						data
					} = res.data;
					_.xyList = data.data;

				});
			},
		},

	};
</script>

<style lang="scss">
	.form {
		box-sizing: border-box;
		padding: 50rpx 20rpx;
	}

	.i_box {
		box-sizing: border-box;
		padding: 20rpx;
		background-color: white;
		border-radius: 25rpx;
		margin-bottom: 50rpx;
	}

	.btn {
		width: 85%;
		background-color: #4ac364;
		color: white;
		text-align: center;
		box-sizing: border-box;
		padding: 15rpx 0;
		margin: 20rpx auto;
		border-radius: 25rpx;
	}

	.agree {
		/* position: fixed;
		bottom: 45rpx; */
		width: 100%;
		text-align: center;
		font-size: 28rpx;
		margin-top: 40rpx;
	}

	.ag_box {
		display: flex;
		box-sizing: border-box;
		padding: 0 20rpx;
		position: fixed;
		bottom: 160rpx;
		left: 0;
		justify-content: center;
	}

	.text_box {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}

	.icondanxuanfuxuan {
		color: #4ac364;

	}

	.iconfont {
		margin-right: 10rpx;
	}

	.protocol {
		color: #4ac364;
	}
</style>